package com.k.designpattern.creational.builder.beanbuilder2;

/**
 * @author kk
 */
public class Cat {
    private Long id;
    private String name;
    private String color;

    public Cat() {
    }

    public Cat(Long id, String name, String color) {
        this.id = id;
        this.name = name;
        this.color = color;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", color='" + color + '\'' +
                '}';
    }

    /**
     * ex builder pattern
     * @return builder
     */
    public static CatBuilder newBuilder(){
        return new CatBuilder();
    }

    public static class CatBuilder{
        private Long id;
        private String name;
        private String color;

        public CatBuilder id(Long id) {
            this.id = id;
            return this;
        }
        public CatBuilder name(String name) {
            this.name = name;
            return this;
        }
        public CatBuilder color(String color) {
            this.color = color;
            return this;
        }

        public Cat build() {
            return new Cat(this.id, this.name, this.color);
        }

    }
}
